/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
"use strict";

var $protobuf = require("protobufjs/minimal");

// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});

$root.msg = (function() {

    /**
     * Namespace msg.
     * @exports msg
     * @namespace
     */
    var msg = {};

    msg.Emoji = (function() {

        /**
         * Properties of an Emoji.
         * @memberof msg
         * @interface IEmoji
         * @property {string|null} [content] Emoji content
         */

        /**
         * Constructs a new Emoji.
         * @memberof msg
         * @classdesc Represents an Emoji.
         * @implements IEmoji
         * @constructor
         * @param {msg.IEmoji=} [properties] Properties to set
         */
        function Emoji(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * Emoji content.
         * @member {string} content
         * @memberof msg.Emoji
         * @instance
         */
        Emoji.prototype.content = "";

        /**
         * Creates a new Emoji instance using the specified properties.
         * @function create
         * @memberof msg.Emoji
         * @static
         * @param {msg.IEmoji=} [properties] Properties to set
         * @returns {msg.Emoji} Emoji instance
         */
        Emoji.create = function create(properties) {
            return new Emoji(properties);
        };

        /**
         * Encodes the specified Emoji message. Does not implicitly {@link msg.Emoji.verify|verify} messages.
         * @function encode
         * @memberof msg.Emoji
         * @static
         * @param {msg.IEmoji} message Emoji message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Emoji.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            if (message.content != null && Object.hasOwnProperty.call(message, "content"))
                writer.uint32(/* id 1, wireType 2 =*/10).string(message.content);
            return writer;
        };

        /**
         * Encodes the specified Emoji message, length delimited. Does not implicitly {@link msg.Emoji.verify|verify} messages.
         * @function encodeDelimited
         * @memberof msg.Emoji
         * @static
         * @param {msg.IEmoji} message Emoji message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Emoji.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes an Emoji message from the specified reader or buffer.
         * @function decode
         * @memberof msg.Emoji
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {msg.Emoji} Emoji
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Emoji.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.msg.Emoji();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.content = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            return message;
        };

        /**
         * Decodes an Emoji message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof msg.Emoji
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {msg.Emoji} Emoji
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Emoji.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies an Emoji message.
         * @function verify
         * @memberof msg.Emoji
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        Emoji.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (message.content != null && message.hasOwnProperty("content"))
                if (!$util.isString(message.content))
                    return "content: string expected";
            return null;
        };

        /**
         * Creates an Emoji message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof msg.Emoji
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {msg.Emoji} Emoji
         */
        Emoji.fromObject = function fromObject(object) {
            if (object instanceof $root.msg.Emoji)
                return object;
            var message = new $root.msg.Emoji();
            if (object.content != null)
                message.content = String(object.content);
            return message;
        };

        /**
         * Creates a plain object from an Emoji message. Also converts values to other types if specified.
         * @function toObject
         * @memberof msg.Emoji
         * @static
         * @param {msg.Emoji} message Emoji
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        Emoji.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults)
                object.content = "";
            if (message.content != null && message.hasOwnProperty("content"))
                object.content = message.content;
            return object;
        };

        /**
         * Converts this Emoji to JSON.
         * @function toJSON
         * @memberof msg.Emoji
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        Emoji.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return Emoji;
    })();

    msg.Text = (function() {

        /**
         * Properties of a Text.
         * @memberof msg
         * @interface IText
         * @property {string|null} [content] Text content
         */

        /**
         * Constructs a new Text.
         * @memberof msg
         * @classdesc Represents a Text.
         * @implements IText
         * @constructor
         * @param {msg.IText=} [properties] Properties to set
         */
        function Text(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * Text content.
         * @member {string} content
         * @memberof msg.Text
         * @instance
         */
        Text.prototype.content = "";

        /**
         * Creates a new Text instance using the specified properties.
         * @function create
         * @memberof msg.Text
         * @static
         * @param {msg.IText=} [properties] Properties to set
         * @returns {msg.Text} Text instance
         */
        Text.create = function create(properties) {
            return new Text(properties);
        };

        /**
         * Encodes the specified Text message. Does not implicitly {@link msg.Text.verify|verify} messages.
         * @function encode
         * @memberof msg.Text
         * @static
         * @param {msg.IText} message Text message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Text.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            if (message.content != null && Object.hasOwnProperty.call(message, "content"))
                writer.uint32(/* id 1, wireType 2 =*/10).string(message.content);
            return writer;
        };

        /**
         * Encodes the specified Text message, length delimited. Does not implicitly {@link msg.Text.verify|verify} messages.
         * @function encodeDelimited
         * @memberof msg.Text
         * @static
         * @param {msg.IText} message Text message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Text.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a Text message from the specified reader or buffer.
         * @function decode
         * @memberof msg.Text
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {msg.Text} Text
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Text.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.msg.Text();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.content = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            return message;
        };

        /**
         * Decodes a Text message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof msg.Text
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {msg.Text} Text
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Text.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a Text message.
         * @function verify
         * @memberof msg.Text
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        Text.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (message.content != null && message.hasOwnProperty("content"))
                if (!$util.isString(message.content))
                    return "content: string expected";
            return null;
        };

        /**
         * Creates a Text message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof msg.Text
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {msg.Text} Text
         */
        Text.fromObject = function fromObject(object) {
            if (object instanceof $root.msg.Text)
                return object;
            var message = new $root.msg.Text();
            if (object.content != null)
                message.content = String(object.content);
            return message;
        };

        /**
         * Creates a plain object from a Text message. Also converts values to other types if specified.
         * @function toObject
         * @memberof msg.Text
         * @static
         * @param {msg.Text} message Text
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        Text.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults)
                object.content = "";
            if (message.content != null && message.hasOwnProperty("content"))
                object.content = message.content;
            return object;
        };

        /**
         * Converts this Text to JSON.
         * @function toJSON
         * @memberof msg.Text
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        Text.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return Text;
    })();

    /**
     * TYPE enum.
     * @name msg.TYPE
     * @enum {number}
     * @property {number} EMOJI=0 EMOJI value
     * @property {number} TEXT=1 TEXT value
     */
    msg.TYPE = (function() {
        var valuesById = {}, values = Object.create(valuesById);
        values[valuesById[0] = "EMOJI"] = 0;
        values[valuesById[1] = "TEXT"] = 1;
        return values;
    })();

    msg.Msg = (function() {

        /**
         * Properties of a Msg.
         * @memberof msg
         * @interface IMsg
         * @property {msg.TYPE|null} [type] Msg type
         * @property {msg.IEmoji|null} [emoji] Msg emoji
         * @property {msg.IText|null} [text] Msg text
         */

        /**
         * Constructs a new Msg.
         * @memberof msg
         * @classdesc Represents a Msg.
         * @implements IMsg
         * @constructor
         * @param {msg.IMsg=} [properties] Properties to set
         */
        function Msg(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * Msg type.
         * @member {msg.TYPE} type
         * @memberof msg.Msg
         * @instance
         */
        Msg.prototype.type = 0;

        /**
         * Msg emoji.
         * @member {msg.IEmoji|null|undefined} emoji
         * @memberof msg.Msg
         * @instance
         */
        Msg.prototype.emoji = null;

        /**
         * Msg text.
         * @member {msg.IText|null|undefined} text
         * @memberof msg.Msg
         * @instance
         */
        Msg.prototype.text = null;

        // OneOf field names bound to virtual getters and setters
        var $oneOfFields;

        /**
         * Msg data.
         * @member {"emoji"|"text"|undefined} data
         * @memberof msg.Msg
         * @instance
         */
        Object.defineProperty(Msg.prototype, "data", {
            get: $util.oneOfGetter($oneOfFields = ["emoji", "text"]),
            set: $util.oneOfSetter($oneOfFields)
        });

        /**
         * Creates a new Msg instance using the specified properties.
         * @function create
         * @memberof msg.Msg
         * @static
         * @param {msg.IMsg=} [properties] Properties to set
         * @returns {msg.Msg} Msg instance
         */
        Msg.create = function create(properties) {
            return new Msg(properties);
        };

        /**
         * Encodes the specified Msg message. Does not implicitly {@link msg.Msg.verify|verify} messages.
         * @function encode
         * @memberof msg.Msg
         * @static
         * @param {msg.IMsg} message Msg message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Msg.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            if (message.type != null && Object.hasOwnProperty.call(message, "type"))
                writer.uint32(/* id 11, wireType 0 =*/88).int32(message.type);
            if (message.emoji != null && Object.hasOwnProperty.call(message, "emoji"))
                $root.msg.Emoji.encode(message.emoji, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim();
            if (message.text != null && Object.hasOwnProperty.call(message, "text"))
                $root.msg.Text.encode(message.text, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim();
            return writer;
        };

        /**
         * Encodes the specified Msg message, length delimited. Does not implicitly {@link msg.Msg.verify|verify} messages.
         * @function encodeDelimited
         * @memberof msg.Msg
         * @static
         * @param {msg.IMsg} message Msg message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Msg.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a Msg message from the specified reader or buffer.
         * @function decode
         * @memberof msg.Msg
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {msg.Msg} Msg
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Msg.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.msg.Msg();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 11:
                    message.type = reader.int32();
                    break;
                case 12:
                    message.emoji = $root.msg.Emoji.decode(reader, reader.uint32());
                    break;
                case 13:
                    message.text = $root.msg.Text.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            return message;
        };

        /**
         * Decodes a Msg message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof msg.Msg
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {msg.Msg} Msg
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Msg.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a Msg message.
         * @function verify
         * @memberof msg.Msg
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        Msg.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            var properties = {};
            if (message.type != null && message.hasOwnProperty("type"))
                switch (message.type) {
                default:
                    return "type: enum value expected";
                case 0:
                case 1:
                    break;
                }
            if (message.emoji != null && message.hasOwnProperty("emoji")) {
                properties.data = 1;
                {
                    var error = $root.msg.Emoji.verify(message.emoji);
                    if (error)
                        return "emoji." + error;
                }
            }
            if (message.text != null && message.hasOwnProperty("text")) {
                if (properties.data === 1)
                    return "data: multiple values";
                properties.data = 1;
                {
                    var error = $root.msg.Text.verify(message.text);
                    if (error)
                        return "text." + error;
                }
            }
            return null;
        };

        /**
         * Creates a Msg message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof msg.Msg
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {msg.Msg} Msg
         */
        Msg.fromObject = function fromObject(object) {
            if (object instanceof $root.msg.Msg)
                return object;
            var message = new $root.msg.Msg();
            switch (object.type) {
            case "EMOJI":
            case 0:
                message.type = 0;
                break;
            case "TEXT":
            case 1:
                message.type = 1;
                break;
            }
            if (object.emoji != null) {
                if (typeof object.emoji !== "object")
                    throw TypeError(".msg.Msg.emoji: object expected");
                message.emoji = $root.msg.Emoji.fromObject(object.emoji);
            }
            if (object.text != null) {
                if (typeof object.text !== "object")
                    throw TypeError(".msg.Msg.text: object expected");
                message.text = $root.msg.Text.fromObject(object.text);
            }
            return message;
        };

        /**
         * Creates a plain object from a Msg message. Also converts values to other types if specified.
         * @function toObject
         * @memberof msg.Msg
         * @static
         * @param {msg.Msg} message Msg
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        Msg.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults)
                object.type = options.enums === String ? "EMOJI" : 0;
            if (message.type != null && message.hasOwnProperty("type"))
                object.type = options.enums === String ? $root.msg.TYPE[message.type] : message.type;
            if (message.emoji != null && message.hasOwnProperty("emoji")) {
                object.emoji = $root.msg.Emoji.toObject(message.emoji, options);
                if (options.oneofs)
                    object.data = "emoji";
            }
            if (message.text != null && message.hasOwnProperty("text")) {
                object.text = $root.msg.Text.toObject(message.text, options);
                if (options.oneofs)
                    object.data = "text";
            }
            return object;
        };

        /**
         * Converts this Msg to JSON.
         * @function toJSON
         * @memberof msg.Msg
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        Msg.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return Msg;
    })();

    return msg;
})();

module.exports = $root;
